package cn.net.yugu.doraemon.netty.protocol.msg22;

import cn.net.yugu.doraemon.netty.protocol.MsgCode;
import io.netty.buffer.ByteBuf;

/**
 * 开门通知
 */
public class Msg221000004 extends Msg221 {

    public String cabinetId;
    public byte lockNum; //锁号
    public byte boxType; //箱子类型
    public byte openBoxStatus; //箱子类型 // 开箱门状态 0:开所有 1:开空箱 2:开满箱
    public int userId;

    @Override
    public int getMsgCode() {
        return MsgCode.MSG_221000004.getCode();
    }

    @Override
    public void readData(ByteBuf buffer) {
        cabinetId = readString(buffer);
        lockNum = buffer.readByte();
        boxType = buffer.readByte();
        openBoxStatus = buffer.readByte();
        if(buffer.readableBytes() > 2){
            userId = buffer.readInt();
        }
    }

    @Override
    public void writeData(ByteBuf buffer) {
        writeString(buffer, cabinetId);
        buffer.writeByte(lockNum);
        buffer.writeByte(boxType);
        buffer.writeByte(openBoxStatus);
        buffer.writeInt(userId);
    }
}
